﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Enterprise.DataFactory;

namespace Enterprise.Data.Kaifabu
{
    public class DanweiData
    {
        /// <summary>
        /// 获取数据列表
        /// </summary>
        /// <param name="strWhere"></param>
        /// <returns></returns>
        public System.Data.DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select DWMC,DWMCRU ");
            strSql.Append(" FROM KFB_CHANLIANGDW ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return  DbExecute.GetDataSet(strSql.ToString());
        }

        public void Add(string dwmc, string dwmcru)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("insert into KFB_CHANLIANGDW(DWMC,DWMCRU) values('"+dwmc+"','"+dwmcru+"')");            
            DbExecute.ExecuteSql(sb.ToString());
        }

        public bool Update(string dwmc, string dwmcru)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update KFB_CHANLIANGDW set ");
            if (dwmcru != null)
            {
                strSql.Append("DWMCRU='" + dwmcru + "',");
            }
            else
            {
                strSql.Append("DWMCRU= null ,");
            }
            int n = strSql.ToString().LastIndexOf(",");
            strSql.Remove(n, 1);
            strSql.Append(" where DWMC='" + dwmc + "' ");
            int rowsAffected = DbExecute.ExecuteSql(strSql.ToString());
            if (rowsAffected > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}
